1. Field of the Invention
The present invention relates to an image processing apparatus, and more particularly to an image processing apparatus and method which can more realistically display reflected light such as diffused light and specular light in relation to a light source; the present invention also relates to a recording medium for storing a program which has a computer execute an image processing procedure.
2. Description of the Related Art
Computer simulations and computer games require image processing, for generating image data for a display screen according to the input data provided, to generate more realistic images in real time. Before now, image processing comprised the following: finding coordinates for flat, multi-sided figures or polygons within a three-dimensional space according to the input data and the like; carrying out perspective conversion to two dimensional coordinates of the display screen, for polygons located within the display screen; and generating color data for each pixel in the polygon.
In such an instance, the polygon data used comprises vertex data, such as color or brightness data, normal vectors, and the three-dimensional coordinates of the vertexes of the polygon. With the vertex data based on a two-dimensional coordinate plane, a rendering process generates color data by performing interpolation (linear interpolation) according to a linear function based on the vertex data for each pixel in the polygon.
In order for the display of more realistic images, the effects of the light source must be reflected in the image. Light sources include point light sources, such as sunlight, with very high brightness; light sources such as a spotlight or laser light source, having directionality and high brightness in that direction; and light sources such as starlight, with low brightness, but with directionality and which are reflected by a mirror surface or the like. Light from such light sources is reflected by an object. This reflection can be classified as diffused reflection or specular reflection. The diffused light from diffused reflection is reflected uniformly in all directions by an object. On the other hand, the specular light from specular reflection is the reflection of light with directionality and is reflected with directionality in a direction wherein the angle of reflection is equal to the angle of incidence. Diffused light, such as the midday sun, includes diffused light due to direct illumination from the sun and ambient light or environmental light from light reflected off surrounding objects. Because environmental light consists of innumerable light sources, environmental light is generally processed as a constant term for diffused light in image processing using computers.
The aforementioned diffused light and specular light are characterized by high brightness within a specified area of illumination and decreasing brightness at the periphery of that area. For example, in a field illuminated by a spotlight, only a limited area is an area with high brightness. Specular light from a light source reflected by a mirror surface likewise has high brightness in a limited area.
The color data of the vertex data composing the aforementioned polygon data must be generated with consideration given to the object""s color, as well as brightness due to the aforementioned reflected light, and the color of the light itself.
However, the rendering process in image processing using polygons generally uses the Gouraud shading method, using linear interpolation of vertex data. For this reason, effective lighting processing is not possible, depending on the positional relationship of that area and the polygon, in the case of high brightness in a uniform area such as with the diffused light and specular light.
FIG. 12 is a drawing to explain the problems with the Gouraud shading method. In this figure, a spotlight 10 directly illuminates one portion of a triangular polygon 1, comprising vertexes A, B, and C. Consequently, diffused light is generated in this area 10. For this reason, lighting processing reflecting the color of the spotlight and the high brightness must be carried out for this area 10. However, none of the vertexes of the polygon 1 is located within the area 10 and as a result, nothing is reflected in the vertex brightness and color data. The diffused light of the area 10 is therefore not reflected in the polygon 1.
FIG. 13 is a drawing to explain further problems with the Gouraud shading method. In this figure, only one portion, including the vertex C of a triangular polygon 1 comprising vertexes A, B, and C, is illuminated. In this case, lighting processing using diffused light is carried out for the vertex C, but not for vertexes A and B. When the rendering process using the Gouraud shading method with linear interpolation is carried out, the results are then as shown in the lower portion of FIG. 13. The area 12 in the right half of the polygon 1 has high brightness and reflects the color of the light source, but gradually toward the left side (in a linear manner), brightness becomes low and the color of the light source is not reflected. Brightness becomes low in the area 14 in the left half.
Such a display can not correctly show the illumination of only a portion at the left side of the polygon 1 as shown in the upper portion of FIG. 13.
FIG. 14 is a drawing to explain further problems with the Gouraud shading method. In this figure, a spotlight, or the like, illuminates an object comprising a plurality of polygons. The edge of the illuminated area 10 forms a smooth circle. With the Gouraud shading method as shown in FIG. 13, only the linear changes, according to linear interpolation, can be displayed for the portions of the polygons with vertexes located within the area 10. Consequently, the edge becomes uneven as shown with the dotted line 12 in the figure. Also, as shown in FIG. 12, the lighting processing is not carried out for a polygon when the area 10 overlaps a portion of polygon but none of its vertexes is located within the area 10. In such case, also the edge of the area 10 becomes uneven in FIG. 14.
Furthermore, the luminous intensity within the area 10 is, generally speaking, great at the center and small at the edges. It is difficult to reproduce this distribution of luminous intensity in a realistic manner using linear interpolation in the Gouraud shading method.
Meanwhile, another image processing method, the Phong shading method, has been proposed. In this method, the normal vector is found for each pixel and lighting processing with the normal vector and light source vector is performed for each pixel. However, the Phong shading method requires an enormous number of calculations and is therefore not realistic for game apparatuses and simulators which require real time processing.
In view of the aforementioned issues, it is an object of the present invention to provide an image processing apparatus and method, able to perform more realistic lighting processing, and a recording medium for storing a program which has a computer execute the procedure.
It is another object of the present invention to provide an image processing apparatus and method, which can perform more realistic lighting processing and minimize increases in calculations while resolving the problems with Gouraud shading, and a recording medium for storing a program which has a computer execute the procedure.
In order to achieve the aforementioned objects, the present invention detects polygons located in a region of diffused light or specular light, divides that polygon and generates subdivided polygons, and for those polygons, carries out lighting processing and rendering processing using linear interpolation according to the conventional Gouraud shading method. In consideration of the efficiency of the image processing, the present invention does not subdivide all the polygons, but rather subdivides the polygons located within the area of diffused light or specular light. Or, the present invention subdivides only those polygons located within areas where the intensity of the diffused light or specular light varies.
With the aforementioned invention, only the parts of the polygons located within areas of diffused light or specular light are subdivided and other polygons are processed at their original size as before. Consequently, linear interpolation with the conventional Gouraud shading method is carried out for the subdivided polygons in areas where changes in brightness and color are to be effectively displayed with lighting processing. More realistic lighting processing can thereby be used to generate images without a corresponding increase in processing.
To attain the aforementioned objects, the present invention is an image processing apparatus, for generating image data from data for a plurality of polygons, comprising: vertex data generating portion for generating polygon data comprising vertex data which includes vertex coordinates, color or brightness data, and light source data comprising data of illuminated area by a light source; dividing those of the aforementioned plurality of polygons which are located within the illuminated area to generate new vertex data; and carrying out processing of reflected light in relation to the light source, for the color or brightness data of the vertexes located within the illuminated area; and a rendering processing portion for generating color data for the pixels within the aforementioned polygons using the aforementioned vertex coordinate, color or brightness data generated above.